package net.udp;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UDPDiscardClient
{
	public final static int DEFAULT_PORT  = 9;
	public static void main(String[] args)
	{
		String hostname;
		int port = DEFAULT_PORT;
		hostname = "localhost";
		try
		{
			InetAddress server = InetAddress.getByName(hostname);
			BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
			DatagramSocket theSocket = new DatagramSocket();
			while(true)
			{
				String theLine = userInput.readLine();
				if(theLine.endsWith("."))
				{
					break;
				}
				byte[] data = theLine.getBytes("UTF-8");
				DatagramPacket theOutput = new DatagramPacket(data, data.length,server,port);
				theSocket.send(theOutput);
			}
		}
		catch (Exception e)
		{
		}
	}
}
